package com.wangsh.usersCenter.web.head.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wangsh.usersCenter.common.controller.BaseController;
import com.wangsh.usersCenter.common.util.ConstatFinalUtil;

/**
 * 	不需要登陆的Controller 
 * 	@author wangsh
 */
@Controller
public class NoLoginClientController extends BaseController
{
	/**
	 * 打开登陆页面
	 * @return
	 */
	@RequestMapping("/login")
	public String login(HttpServletRequest request)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--login--");
		return "/head/login";
	}
	
	/**
	 * 登陆提交操作
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/loginSubmit")
	public String loginSubmit(HttpServletRequest request,HttpSession session , HttpServletResponse response,Model model) throws IOException
	{
		ConstatFinalUtil.SYS_LOGGER.info("--loginSubmit--");
		String id = request.getParameter("id");
		if("1".equalsIgnoreCase(id))
		{
			/* 登陆成功 */
			session.setAttribute("users", "1");
			return "redirect:/head/users/main.htm";
		}
		return this.login(request);
	}
}
